import KZJRequest from '../index'
import { TAccount, ILoginResult } from './type'
import { IDataType } from '../type'

enum LoginApi {
  AccountLogin = '/login',
  LoginUserInfo = '/users/', // 用法: /users/1
  UserMenus = '/role/' // 用法: role/1/menu
}

export function accountLogin(account: TAccount) {
  return KZJRequest.post<IDataType<ILoginResult>>({
    url: LoginApi.AccountLogin,
    data: account,
    showLoading: true
  })
}

export function requestUserInfoById(id: number) {
  return KZJRequest.get<IDataType>({
    url: LoginApi.LoginUserInfo + id
  })
}

export function requestUserMenusByRoleId(id: number) {
  return KZJRequest.get<IDataType>({
    url: LoginApi.UserMenus + id + '/menu'
  })
}
